package com.doge.calcalbum.utils

import android.content.pm.PackageManager
import com.doge.calcalbum.business.account.AppUserViewModel


/** 用户协议 */
const val urlUserPolicy = "http://www.inspace.vip/useTerm.html"
/** 隐私协议 */
const val urlPrivacy = "http://www.inspace.vip/policy.html"
/** 会员服务充值协议 */
const val urlVipBuy = "http://www.inspace.vip/payrule.html"

/** 清理时间 */
const val TRASH_CLEAR_DELAY_TIME = 30 * 24 * 60 * 60 * 1000L

const val deviceType = "1"
const val PAGE_SIZE = 10
val freeLimitCount: Int get() = AppUserViewModel.get().self().fuc ?: 10

val appVersionName by lazy {
    try {
        appContext.packageManager.getPackageInfo(appContext.packageName, 0).versionName
            ?: ""
    } catch (ignored: PackageManager.NameNotFoundException) {
        ""
    }
}

val appVersionCode: Int by lazy {
    try {
        appContext.packageManager.getPackageInfo(appContext.packageName, 0).versionCode
    } catch (ignored: PackageManager.NameNotFoundException) {
        0
    }
}

val appChannel: String by lazy {
    try {
        val pm: PackageManager = appContext.packageManager
        val appInfo = pm.getApplicationInfo(appContext.packageName, PackageManager.GET_META_DATA)
        appInfo.metaData.getString("APP_CHANNEL") ?: "default"
    } catch (ignored: PackageManager.NameNotFoundException) {
        "default"
    }
}

val disableSkin by lazy { appChannel.contains("xiaomi") }